package com.foolishbird.sdk.ui.assist;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.ArrayList;
import java.util.List;

public class LoginBindPagerAdapter extends FragmentPagerAdapter {

    private static final short DEFAULT_MAX_PAGER_COUNT = 2;

    private final List<Fragment> fragments = new ArrayList<>(DEFAULT_MAX_PAGER_COUNT);

    public LoginBindPagerAdapter(FragmentManager fragment, List<Fragment> fragments) {
        super(fragment);
        this.fragments.clear();
        this.fragments.addAll(fragments);
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(Math.min(position, fragments.size() - 1));
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

}
